setShareHistoryFileName

open fun setShareHistoryFileName(shareHistoryFile: String)(source)

Sets the file name of a file for persisting the share history which history will be used for ordering share targets. This file will be used for all view created by onCreateActionView. Defaults to DEFAULT_SHARE_HISTORY_FILE_NAME. Set to null if share history should not be persisted between sessions.

Note: The history file name can be set any time, however only the action views created by onCreateActionView after setting the file name will be backed by the provided file. Therefore, if you want to use different history files for sharing specific types of content, every time you change the history file with setShareHistoryFileName you must call supportInvalidateOptionsMenu to recreate the action view. You should not call supportInvalidateOptionsMenu from onCreateOptionsMenu.

private void doShare(Intent intent) {
    if (IMAGE.equals(intent.getMimeType())) {
        mShareActionProvider.setHistoryFileName(SHARE_IMAGE_HISTORY_FILE_NAME);
    } else if (TEXT.equals(intent.getMimeType())) {
        mShareActionProvider.setHistoryFileName(SHARE_TEXT_HISTORY_FILE_NAME);
    }
    mShareActionProvider.setIntent(intent);
    supportInvalidateOptionsMenu();
}

Parameters

shareHistoryFile

The share history file name.